﻿using Shop.RemoteModel.GoodsSpec;
using Shop.RemoteModel.GoodsSpec.Model;
using Shop.StoreGatewayModular.Interface;

namespace Shop.StoreGatewayModular.Service
{
    internal class GoodsSpecService : IGoodsSpecService
    {
        public void DeleteSpec (long specId)
        {
            new DeleteGoodsSpec
            {
                Id = specId
            }.Send();
        }
        public bool SetSkuState (SkuStateSet state)
        {
            return new SetGoodsSkuState
            {
                State = state
            }.Send();
        }
        public void SyncSku (long goodsId)
        {
            new SyncSku
            {
                GoodsId = goodsId
            }.SyncSend();
        }
        public Dictionary<long, int> SetSpecSort (long id, int sort)
        {
            return new SetSpecSort
            {
                Id = id,
                Sort = sort
            }.Send();
        }
        public Dictionary<long, int> SetGroupSort (long id, int sort)
        {
            return new SetSpecGroupSort
            {
                Id = id,
                Sort = sort
            }.Send();
        }
        public GoodsSpecSku[] GetSpecSku (long goodsId)
        {
            return new GetSkuSpecGroup
            {
                GoodsId = goodsId
            }.Send();
        }

        public GoodsSpecGroup[] GetSpecGroup (long goodsId)
        {
            return new GetSpecGroup
            {
                GoodsId = goodsId
            }.Send();
        }

        public GoodsSpecGroup[] Sync (long goodsId, long categoryId)
        {
            return new SyncSpecGroup
            {
                CategoryId = categoryId,
                GoodsId = goodsId
            }.Send();
        }
        public bool SetSpec (long id, GoodsSpecSet datum)
        {
            return new SetGoodsSpec
            {
                Id = id,
                Datum = datum
            }.Send();
        }
        public GoodsSpec AddSpec (GoodsSpecAdd datum)
        {
            return new AddGoodsSpec
            {
                Datum = datum
            }.Send();
        }

        public bool SetGroup (long id, string name)
        {
            return new SetSpecGroup
            {
                Id = id,
                Name = name
            }.Send();
        }

        public long AddGroup (SpecGroupAdd datum)
        {
            return new AddSpecGroup
            {
                Datum = datum
            }.Send();
        }

        public void DeleteGroup (long id)
        {
            new DeleteSpecGroup
            {
                Id = id
            }.Send();
        }

        public void DeleteSkuSpec (long goodsId, long[] specId)
        {
            new DeleteSkuSpec
            {
                GoodsId = goodsId,
                SpecId = specId
            }.Send();
        }
    }
}
